#include <iostream>
#include <vector>
using namespace std;

int knapsack(int n, int c, int w[], int v[]) {
    vector<int> dp(c + 1, 0);
    for (int i = 0; i < n; i++) 
        for (int j = c; j >= w[i]; j--) 
            dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
    return dp[c];
}

int main() {
    int n = 5, c = 10;
    int w[] = {2,2,6,5,4}, v[] = {6,3,5,4,6};
    int ans = knapsack(n, c, w, v);
    cout << "最大价值为: " << ans << endl;
    return 0;
}
